'''河洛塔'''

global step
step = 0


def move(element, yuan, mubiao, nowhanvels):
    global step
    step = step+1
    print("------第{}步------".format(step))
    print("{0}:{1}---->{2}".format(element, yuan, mubiao))
    if (len(nowhanvels[yuan]) > 1):
        nowhanvels[yuan] = nowhanvels[yuan].replace(str(element) + ",", "")
    else:
        nowhanvels[yuan] = nowhanvels[yuan].replace(str(element), "")
    if (nowhanvels[mubiao] == ""):
        nowhanvels[mubiao] = str(element)
    else:
        nowhanvels[mubiao] = str(element) + "," + nowhanvels[mubiao]
    print("A:{0}".format(nowhanvels["A"]))
    print("B:{0}".format(nowhanvels["B"]))
    print("C:{0}".format(nowhanvels["C"]))


def heluota(heluo, yuan, temp, mubiao, nowhavels):
    if len(heluo) == 1:
        move(heluo[0], yuan, mubiao, nowhavels)
        return
    max = heluo[len(heluo) - 1]
    heluonew = []
    for i in range(0, len(heluo) - 1):
        heluonew.append(heluo[i])
    heluota(heluonew, yuan, mubiao, temp, nowhavels)
    move(max, yuan, mubiao, nowhavels)
    heluota(heluonew, temp, yuan, mubiao, nowhavels)


heluo = [1, 2, 3, 4, 5]
heluo2 = []
for i in heluo:
    heluo2.append(str(i))
nowhave = {"A": ",".join(heluo2), "B": "", "C": ""}
heluota(heluo, "A", "B", "C", nowhave)
